package leetcode_1601_1700;

import java.util.Arrays;

public class LeeCode_1605 {
    public static void main(String[] args) {
        int[][] ints = restoreMatrix(new int[]{5, 7, 10}, new int[]{8, 6, 8});
        for (int[] anInt : ints) {
            System.out.println(Arrays.toString(anInt));
        }
    }
    private static int[][] restoreMatrix(int[] rowSum, int[] colSum) {
        int m = rowSum.length;
        int n = colSum.length;
        int[][] res = new int[m][n];
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                res[i][j] = Math.min(rowSum[i], colSum[j]);
                rowSum[i] -= res[i][j];
                colSum[j] -= res[i][j];
            }
        }
        return res;
    }
}
